package com.bdqn.boot.controller;

import com.bdqn.boot.beans.User;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.Arrays;
import java.util.List;

/**
 * @author Hasee
 * @version 1.0
 * @className ThymeleafController
 * @description TODD
 * @date 2025/2/24 15:34
 */
@Controller
public class ThymeleafController {
    @RequestMapping("/test")
    public String test(Model model) {
        model.addAttribute("msg", "Hello World");
        model.addAttribute("msg2", "http://www.baidu.com");
        return "success";
    }

    @GetMapping("/dynamic_table")
    public String dynamic_table(Model model){
        //表格内容的遍历
        List<User> users = Arrays.asList(new User("zhangsan", 12),
                new User("lisi", 2),
                new User("haha", 12),
                new User("hehe ", 11));
        model.addAttribute("users",users);

        return "dynamic_table";
    }
}
